﻿using System.Collections.Generic;
using UnityEngine;

namespace Framework
{

    public class ObjectPoolManager : FrameworkComponent
    {
        private Dictionary<string, IObjectPool> m_objects;

        public ObjectPoolManager()
        {
            m_objects = new Dictionary<string, IObjectPool>();
        }
        public ObjectPool<T> CreatObjectPool<T>(string name, float expireTime,float autoReleaseTime) where T : ObjectBase
        {
            var pool=new ObjectPool<T>(name,expireTime,autoReleaseTime);
            m_objects.TryAdd(name, pool);
            return pool;
        }
       public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
       {
           foreach (var objectPool in m_objects)
           {
               objectPool.Value.Update(elapseSeconds,realElapseSeconds);
           }

       }

       public override void Shutdown()
       {

       }
    }

}